<template>
  <!DOCTYPE html>
  <html>

  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">

    <title>HOME</title>
    <!-- 引入字体图标 -->
    <link rel="stylesheet" href="/fonts/css/font-awesome.css">
    <link rel="stylesheet" href="133.css">
  </head>

  <body>
  <div class="container">
    <div class="item active">
      <img src="../image/wall.jpg" alt="" width="1800px" height="1270px">
      <div class="shadow"></div>
      <div class="content">
        <div class="icon">
          <i class="fa fa-sun-o"></i>
        </div>
        <div class="text">
          <div class="tit">这是标题</div>
          <div class="sub">这是一段描述</div>
        </div>
      </div>
    </div>
    <div class="item">
      <img src="../image/ice.jpg" alt="" width="1800px" height="1270px">
      <div class="shadow"></div>
      <div class="content">
        <div class="icon">
          <i class="fa fa-cloud"></i>
        </div>
        <div class="text">
          <div class="tit">这是标题</div>
          <div class="sub">这是一段描述</div>
        </div>
      </div>
    </div>
    <div class="item">
      <img src="../image/flower.jpg" alt="" width="1800px" height="1270px">
      <div class="shadow"></div>
      <div class="content">
        <div class="icon">
          <i class="fa fa-tint"></i>
        </div>
        <div class="text">
          <div class="tit">这是标题</div>
          <div class="sub">这是一段描述</div>
        </div>
      </div>
    </div>
    <div class="item">
      <img src="../image/background2.jpg" alt="" width="1800px" height="1270px">
      <div class="shadow"></div>
      <div class="content">
        <div class="icon">
          <i class="fa fa-bolt"></i>
        </div>
        <div class="text">
          <div class="tit">这是标题</div>
          <div class="sub">这是一段描述</div>
        </div>
      </div>
    </div>
    <div class="item" >
      <img src="../image/background.png" alt="" width="1800px" height="1270px">
      <div class="shadow"></div>
      <div class="content">
        <div class="icon">
          <i class="fa fa-snowflake-o"></i>
        </div>
        <div class="text">
          <div class="tit">这是标题</div>
          <div class="sub">这是一段描述</div>
        </div>
      </div>
    </div>
  </div>
  <script src="133.js"></script>
  </body>

  </html>
</template>

<script>
export default {

  name: "test"
}
// 获取所有.item元素
//const dept = {
//export function show(){
let items = document.querySelectorAll('.item');

// 设置选中态样式
function setActive(){
  // 遍历所有.item元素，移出active样式
  items.forEach((item)=>{
    item.classList.remove('active');
  })
  // 为当前选中项添加active样式
  this.classList.add('active');
}
// 遍历所有.item元素，分别为其设置点击事件
items.forEach((item)=>{
  item.addEventListener('click',setActive);
})
//}

// export default {
//     show
// }
//};


//export default dept
</script>

<style scoped>
*{
  margin: 0;
  padding: 0;
}
body{
  /* 100%窗口高度 */
  height: 100vh;
  /* 弹性布局 水平+垂直居中 */
  display: flex;
  justify-content: center;
  align-items: center;
  /* 径向渐变背景 */
  background: radial-gradient(circle at top center,#718497,#29323c);
}
.container{
  /* 弹性布局 默认水平排列 */
  display: flex;
  width:180vw;
  max-width: 1800px;
  height: 800px;
  /* 溢出隐藏 */
  overflow: hidden;
}
.item{
  /* 相对定位 */
  position: relative;
  width: 60px;
  margin: 10px;
  cursor: pointer;
  border-radius: 30px;
  /* 保持原有尺寸比例，裁切长边 */
  background-size: cover;
  /* 定位背景图像为正中间 */
  background-position: center;
  /* 过渡效果：时长 贝塞尔曲线 */
  transition: 0.5s cubic-bezier(0.05,0.61,0.41,0.95);
  overflow: hidden;
}
.item .shadow{
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100px;
  transition: 0.5s cubic-bezier(0.05,0.61,0.41,0.95);
}
.item .content{
  display: flex;
  position: absolute;
  left: 10px;
  right: 0;
  bottom: 10px;
  height: 40px;
  transition: 0.5s cubic-bezier(0.05,0.61,0.41,0.95);
}
.item .content .icon{
  min-width: 40px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 16px;
}
.item:nth-child(1) .fa{
  color: #fc6e51;
}
.item:nth-child(2) .fa{
  color: #ffce54;
}
.item:nth-child(3) .fa{
  color: #2ecc71;
}
.item:nth-child(4) .fa{
  color: #5d9cec;
}
.item:nth-child(5) .fa{
  color: #ac92ec;
}
.item .content .text{
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-left: 10px;
  color: #fff;
  width: 100%;
}
.item .content .text div{
  /* 超出显示省略号（需要设置width） */
  width: calc(100% - 70px);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.5s ease-out;
}
.item .content .text .tit{
  font-weight: bold;
  font-size: 18px;
}
.item .content .text .sub{
  /* 设置过渡效果延迟时间 */
  transition-delay: 0.1s;
}
/* 选中态样式 */
.item.active{
  flex: 1;
  margin: 0;
  border-radius: 40px;
}
.item.active .shadow{
  background: linear-gradient(to top,rgba(0,0,0,0.35) 65%,transparent);
}
.item.active .content{
  bottom: 20px;
  left: 20px;
}
.item.active .content .text div{
  opacity: 1;
}
</style>